﻿using LibNiconico.NiconicoApi.Internal;
using LibNiconico.NiconicoApi.User.Thumb;
using LibNiconico.NiconicoApi.Utils;
using LibNiconico.NiconicoApi.Videos.Constant;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace LibNiconico.NiconicoApi.User
{
    /// <summary>
    /// ニコニコユーザーAPIヘルパー
    /// </summary>
    public class NicoUserApiHelper : NicoApiHelperBase
    {
        internal NicoUserApiHelper(NiconicoAuth auth, NiconicoApiInfoGetCreateInfo defaultCreateInfo) : base(auth, defaultCreateInfo) { }


        /// <summary>
        /// ユーザ情報取得
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task<NicoVideoGetThumbUserResponse> GetThumbUserAsync(string userId)
        {
            return await this.GetThumbUserAsync(new NicoVideoGetThumbUserQueryInfo(userId)).ConfigureAwait(false);
        }

        /// <summary>
        /// ユーザ情報取得
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        internal async Task<NicoVideoGetThumbUserResponse> GetThumbUserAsync(NicoVideoGetThumbUserQueryInfo queryInfo)
        {
            using (var api = new NiconicoInfoGetApiHtmlImpl(NicoVideoConstant.NICOVIDEO_URL, CreateMostLoginApiHttpClient()))
            {
                return NicoVideoGetThumbUserResponse.Parse( (await api.GetAsync(queryInfo).ConfigureAwait(false)).Content);
            }
        }
    }
}
